package com.baizhi.syh.controller;


import com.baizhi.syh.VO.PageVO;
import com.baizhi.syh.VO.ResultVO;
import com.baizhi.syh.entity.Category;
import com.baizhi.syh.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
@RequestMapping("Category")//设定访问名
@ResponseBody//响应时转换为Jason格式
@CrossOrigin //解决跨区域问题
public class CategoryController {

    @Autowired
    private CategoryService categoryService;

    //一级目录分页展示
    @RequestMapping("OneShowAll")
    public ResultVO OneShowAll(@RequestBody PageVO pageVO){
        if (pageVO.getPage() == null) {
            pageVO.setPage(1);
        }
        return categoryService.selectOneLevels(pageVO.getPage(), pageVO.getPageSize());
    }
}
